<?
	include_once "WorkflowUpdate.php";
	function execute()
	{
		$sql = "SELECT Id, DocumentId, ActionId FROM ScheduledAction WHERE Date < CURDATE()";
		$actions = query_db($sql);
		
		while ($action = mysql_fetch_array($actions, MYSQL_ASSOC))
		{
			// execute each action
			execute_wf_action($action["DocumentId"], $action["ActionId"]);
			
			// now remove the schedule
			$sql = "DELETE FROM ScheduledAction WHERE Id=" . $action["Id"];
			query_db($sql);
		}
		
		mysql_free_result($actions);
	}
	execute();
?>